build-sys: Move clang-format into justfile
authorColin Walters <walters@verbum.org>
Wed, 25 Jun 2025 17:39:48 +0000 (13:39 -0400)
committerColin Walters <walters@verbum.org>
Thu, 26 Jun 2025 21:06:57 +0000 (17:06 -0400)
We don't need a build to run it, it's more appropriate
there.

Signed-off-by: Colin Walters <walters@verbum.org>
.github/workflows/tests.yml
Justfile
Makefile.am
ci/clang-format.sh [deleted file]

index 5944ebe7497de1e4f14dfdbf6996dc88366952c2..b3074b8302f98b4a112e461edc2df652345d4291 100644 (file)
@@ -38,9 +38,9 @@ jobs:
       # https://github.com/actions/checkout/issues/760
       - name: Mark git checkout as safe
         run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
-      - run: sudo apt install clang-format
+      - run: sudo apt install clang-format just
       - name: Test style
-        run: ./ci/clang-format.sh
+        run: just clang-format-check
   build-integration:
     runs-on: ubuntu-latest
     container: quay.io/coreos-assembler/fcos-buildroot:testing-devel
index 7dee1287ab3eec5bafa37efc4a66fef5b983bd72..6232ba1defb6cbd52710934eadb048dab669f177 100644 (file)
--- a/Justfile
+++ b/Justfile
@@ -49,3 +49,11 @@ build-host-inst: build-host
     make -C target/c install DESTDIR=$(pwd)/target/inst
     tar --sort=name --numeric-owner --owner=0 --group=0 -C target/inst -czf target/inst.tar.gz .
 
+sourcefiles := "git ls-files '**.c' '**.cxx' '**.h' '**.hpp'"
+# Reformat source files
+clang-format:
+    {{sourcefiles}} | xargs clang-format -i
+
+# Check source files against clang-format defaults
+clang-format-check:
+    {{sourcefiles}} | xargs clang-format -i --Werror --dry-run
\ No newline at end of file
index ddaf790ed70566fbd8b6dbe5f9f01200758e0fc6..424b285329df86af57984b0755e3faef47b4d0cb 100644 (file)
@@ -136,10 +136,6 @@ include Makefile-bash.am
 release-tag:
        cd $(srcdir) && git $(srcdir) tag -m "Release $(VERSION)" v$(VERSION)
 
-.PHONY: clang-format
-clang-format:
-       git ls-files '**.c' '**.cxx' '**.h' '**.hpp' | xargs clang-format -i
-
 embed_dependency=tar -C $(srcdir) --append --exclude='.git/*' --transform="s,^embedded-dependencies/,ostree-embeddeps-$${GITVERSION}/embedded-dependencies/," --file=$${TARFILE_TMP}
 
 git_version_rpm = $$(cd $(srcdir) && git describe | sed -e 's,-,\.,g' -e 's,^v,,')
diff --git a/ci/clang-format.sh b/ci/clang-format.sh
deleted file mode 100755 (executable)
index 5bb3394..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/usr/bin/env bash
-# Tests that validate structure of the source code;
-# can be run without building it.
-set -euo pipefail
-
-clang_ver=$(clang-format --version)
-clang_min_ver=15
-version_re=" version ([0-9]+)."
-if [[ $clang_ver =~ $version_re ]]; then
-    if test "${BASH_REMATCH[1]}" -ge "${clang_min_ver}"; then
-        echo -n "checking clang-format... "
-        git ls-files '**.c' '**.cxx' '**.h' '**.hpp' | xargs clang-format --Werror --dry-run
-        echo "ok"
-    else
-        echo "notice: clang-format ${clang_ver}" is too old
-    fi
-else
-    echo "failed to parse clang-format version ${clang_ver}" 1>&2
-    exit 1
-fi